﻿@model IEnumerable<ECatalog.Models.User>

@{
    ViewBag.Title = "Пользователи";
}
<div class="container">
    <div class="row">
        <p>
            @Html.ActionLink("Добавить пользователя", "Register", null, new { @class = "btn btn-primary" })
        </p>
        <table class="table table-bordered table-hover">
            <tr>
                <th>Логин
                </th>
                <th>Администратор
                </th>
                <th>Модератор
                </th>
                <th></th>
            </tr>

            @foreach (var item in Model)
            {
                <tr>
                    <td>
                        @Html.DisplayFor(modelItem => item.Login)
                    </td>
                    <td>
                        @Html.DisplayFor(modelItem => item.IsAdmin)
                    </td>
                    <td>
                        @if (item.IsAdmin)
                        {
                            <input class="check-box" disabled="disabled" type="checkbox" />
                        }
                        else
                        {
                            <input checked="checked" class="check-box" disabled="disabled" type="checkbox" />
                        }
                    </td>
                    <td>
                        @if (item.Login != "admin")
                        {
                            using (@Html.BeginForm("Delete", "User", new {id = item.UserId}, FormMethod.Post))
                            {
                                <button type="submit" class="btn btn-link">Удалить</button>
                            }
                        }
                    </td>
                </tr>
            }

        </table>
    </div>
</div>
